var butObject;
var dateObj;
//var dateLimit;
//获取当前日期的年份
function getCurrentYear() {
	var year = new Date().getYear();
	if(year < 1900) year += 1900;
	return year;
	}


//获取当前日期的月份
function getCurrentMonth() {
	return new Date().getMonth() + 1;
	} 


//获取当前日期的天数
function getCurrentDay() {
	return new Date().getDate();
	}
function positionInfo(object){
	var p_elm = object;
	this.getElementLeft = getElementLeft
	function getElementLeft(){
		var x = 0;
		var elm;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else {elm = document.getElementById(p_elm);}
		while (elm != null){
			if(elm.style.position == 'relative'){
				break;
				}
			else {
				x += elm.offsetLeft;
				elm = elm.offsetParent;
				}
			}
		return parseInt(x);
		}
	this.getElementWidth = getElementWidth;
	function getElementWidth(){
		var elm;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else{elm = document.getElementById(p_elm);}
		return parseInt(elm.offsetWidth);
		}
	this.getElementRight = getElementRight;
	function getElementRight(){
		return getElementLeft(p_elm) + getElementWidth(p_elm);
		}
	this.getElementTop = getElementTop;
	function getElementTop(){
		var y = 0;
		var elm;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else{elm = document.getElementById(p_elm);}
		while (elm != null){
			if(elm.style.position == 'relative'){break;}
			else{
				y+= elm.offsetTop;
				elm = elm.offsetParent;
				}
			}
		return parseInt(y);
		}
	this.getElementHeight = getElementHeight;
	function getElementHeight(){
		var elm;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else{elm = document.getElementById(p_elm);}
		return parseInt(elm.offsetHeight);
		}
	this.getElementBottom = getElementBottom;
	function getElementBottom(){
		return getElementTop(p_elm) + getElementHeight(p_elm);
		}
	}

function CalendarControl() {
	var calendarId = 'calendarCov';
	var currentYear = 0;
	var currentMonth = 0;
	var currentDay = 0;
	
	var selectedYear = 0;
	var selectedMonth = 0;
	var selectedDay = 0;
	var months = ['01','02','03','04','05','06','07','08','09','10','11','12'];
	var dateField = null;
	function getProperty(p_property){
		var p_elm = calendarId;
		var elm = null;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else{elm = document.getElementById(p_elm);}
		if(elm != null){
			if(elm.style){
				elm = elm.style;
				if(elm[p_property]){return elm[p_property];}
				else {return null;}
				}
			else {return null;}
			}
		}
	function setElementProperty(p_property, p_value, p_elmId){
		var p_elm = p_elmId;
		var elm = null;
		if(typeof(p_elm) == "object"){elm = p_elm;}
		else {elm = document.getElementById(p_elm);}
		if((elm != null) && (elm.style != null)){
			elm = elm.style;
			elm[ p_property ] = p_value;
			}
		}

	function setProperty(p_property, p_value) {
	setElementProperty(p_property, p_value, calendarId);
	}

	function getDaysInMonth(year, month) {
		return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
		}

	function getDayOfWeek(year, month, day) {
		var date = new Date(year,month-1,day)
		return date.getDay();
		}

	this.clearDate = clearDate;
	function clearDate() {
		dateField.value = '';
		hide();
		}

	this.setDate = setDate;
	function setDate(year, month, day) {
		if (dateField) {
			if (month < 10) {month = "0" + month;}
			if (day < 10) {day = "0" + day;}
			var dateString = year+"-"+month+"-"+day;
			dateField.value = dateString;
			hide();
			}
		return;
		}

	this.changeMonth = changeMonth;
	function changeMonth(change,dateLimitmin,dateLimitmax) {
		currentMonth = currentMonth*1+change;
		currentDay = 0;
		if(currentMonth > 12) {
			currentMonth = 1;
			currentYear++;
			}
		else if(currentMonth < 1) {
			currentMonth = 12;
			currentYear--;
			}
		
		calendar = document.getElementById(calendarId);
		calendar.innerHTML = calendarDrawTable(dateObj,dateLimitmin,dateLimitmax);
		}

	this.changeYear = changeYear;
	function changeYear(change,dateLimitmin,dateLimitmax) {
		currentYear = currentYear*1+change;
		currentDay = 0;
		calendar = document.getElementById(calendarId);
		calendar.innerHTML = calendarDrawTable(dateObj,dateLimitmin,dateLimitmax);
		}
//绘制日历表格
	function calendarDrawTable(dateObj,dateLimitmin,dateLimitmax){
		var dayOfMonth = 1;
		var validDay = 0;
		var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
		var daysInMonth = getDaysInMonth(currentYear, currentMonth);
		var css_class = null; //CSS class for each day
		
		//求出最大限度的日期
		var hdayDreaw = currentYear+"-"+currentMonth+"-"+daysInMonth;
		var dreawH = new Date(hdayDreaw.replace(/-/g, "/")).getTime();
		
		//求出最小限度的日期
		var ldayDreaw = currentYear+"-"+currentMonth+"-"+dayOfMonth;
		var dreawL = new Date(ldayDreaw.replace(/-/g, "/")).getTime()
		
		
		var todayDate = new Date(dateTodystr.replace(/-/g, "/")).getTime();
		var maxcDate = new Date(dateLimitmax.replace(/-/g, "/")).getTime();
		var mincDate = new Date(dateLimitmin.replace(/-/g, "/")).getTime();	
		var table="";
		table += "<table border='0' cellspacing='0' cellpadding='0' class='calenCov' Author = 'calendar'>";
		table +=   "<tr Author = 'calendar'>";
		table +=     "<td class='calenTitle' Author = 'calendar'>";
		table +=     "<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' Author = 'calendar'>";
		table +=       "<tr Author = 'calendar'>";
		table +=         "<td align='left' Author = 'calendar'>";;
		if((mincDate-dreawL)/(1000*60*60*24*365)>-1){table +=         "<a class='calenYlast' Author = 'calendar'>&nbsp;</a>";}
		else{table +=         "<a href=\"javascript:changeCalendarControlYear(-1,'"+dateLimitmin+"','"+dateLimitmax+"');\" class='calenYlast' Author = 'calendar'>&nbsp;</a>";}
		if((mincDate-dreawL)/(1000*60*60*24*12)>-1){table +=         "<a class='calenMlast' Author = 'calendar'>&nbsp;</a>";}
		else{table +=         "<a href=\"javascript:changeCalendarControlMonth(-1,'"+dateLimitmin+"','"+dateLimitmax+"');\" class='calenMlast' Author = 'calendar'>&nbsp;</a>";}
		table +=         "</td>"
		table +=         "<td align='center' Author = 'calendar'>" + currentYear + "年&nbsp;&nbsp;&nbsp;" + months[currentMonth-1] + "月</td>"
		table +=         "<td align='right' Author = 'calendar'>";
		if((maxcDate-dreawH)/(1000*60*60*24*12)<1){table +=         "<a class='calenMnext' Author = 'calendar'>&nbsp;</a>";}
		else{table +=         "<a href=\"javascript:changeCalendarControlMonth(1,'"+dateLimitmin+"','"+dateLimitmax+"');\" class='calenMnext' Author = 'calendar'>&nbsp;</a>";}
		if((maxcDate-dreawH)/(1000*60*60*24*365)<1){table +=         "<a class='calenYnext' Author = 'calendar'>&nbsp;</a>";}
		else{table +=         "<a href=\"javascript:changeCalendarControlYear(1,'"+dateLimitmin+"','"+dateLimitmax+"');\" class='calenYnext' Author = 'calendar'>&nbsp;</a>";}
		table +=         "</td>";
		table +=       "</tr>";
		table +=     "</table>";
		table +=     "</td>";
		table +=   "</tr>";
		table +=   "<tr Author = 'calendar'>";
		table +=     "<td class='calenBody' Author = 'calendar'>";
		table +=     "<table width='100%' border='0' cellspacing='0' cellpadding='0' Author = 'calendar'>";
		table +=       "<tr Author = 'calendar'>";
		table +=         "<td class='calenBodyCov' Author = 'calendar'>";
		table +=         "<table width='100%' border='0' cellspacing='0' cellpadding='0' Author = 'calendar'>";
		table +=           "<tr Author = 'calendar'>";
		table +=             "<td class='calenHead' Author = 'calendar'>";
		table +=             "<table width='100%' border='0' cellspacing='1' cellpadding='0' Author = 'calendar'>";
		table +=               "<tr Author = 'calendar'>";
		table +=                 "<th align='center' Author = 'calendar'>日</th>";
		table +=                 "<th align='center' Author = 'calendar'>一</th>";
		table +=                 "<th align='center' Author = 'calendar'>二</th>";
		table +=                 "<th align='center' Author = 'calendar'>三</th>";
		table +=                 "<th align='center' Author = 'calendar'>四</th>";
		table +=                 "<th align='center' Author = 'calendar'>五</th>";
		table +=                 "<th align='center' Author = 'calendar'>六</th>";
		table +=               "</tr>";
		table +=             "</table>";
		table +=             "</td>";
		table +=           "</tr>";
		table +=           "<tr Author = 'calendar'>";
		table +=             "<td Author = 'calendar'>";
		table +=             "<table border='0' cellpadding='0' cellspacing='1' Author = 'calendar' class='calenday'>";	
		for(var week=0; week < 6; week++) {
			table += "<tr Author = 'calendar'>";
			for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
				if(week == 0 && startDayOfWeek == dayOfWeek) {validDay = 1;}
				else if(validDay == 1 && dayOfMonth > daysInMonth){validDay = 0;}
				if(validDay) {
					var dayDreaw = currentYear+"-"+currentMonth+"-"+dayOfMonth;
					var dreawDay = new Date(dayDreaw.replace(/-/g, "/")).getTime();
					var selDreaw = selectedYear+"-"+selectedMonth+"-"+selectedDay;
					var dreawSel = new Date(selDreaw.replace(/-/g, "/")).getTime();
					
					//设置默认的选中日期
					if(mincDate-dreawSel>0){
						selectedDay = dateLimitmin.split("-")[2];
						selectedYear = dateLimitmin.split("-")[0];
						selectedMonth = dateLimitmin.split("-")[1];
						}
					if(maxcDate-dreawSel<0){
						selectedDay = dateLimitmax.split("-")[2];
						selectedYear = dateLimitmax.split("-")[0];
						selectedMonth = dateLimitmax.split("-")[1];
						}
					
					//判断是否是选中的日期,然后设置样式
					if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {css_class = 'current';}
					else if (dayOfWeek == 0 || dayOfWeek == 6) {css_class = 'weekend';}
					else {css_class = 'weekday';}
					if(dreawDay-mincDate<0||dreawDay-maxcDate>0){
						table += "<td Author = 'calendar' class='"+css_class+"'>"+dayOfMonth+"</td>";
						}
					else{
						table += "<td Author = 'calendar' class='"+css_class+"'><a href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\" Author = 'calendar'>"+dayOfMonth+"</a></td>";
						}
					dayOfMonth++;
					}
				else {table += "<td class='weeknull' Author = 'calendar'>&nbsp;</td>";}
				}
			table += "</tr>";
			}
		table +=             "</table>";
		table +=             "</td>";
		table +=           "</tr>";
		table +=         "</table>";
		table +=         "</td>";
		table +=       "</tr>";
		table +=       "<tr Author = 'calendar'>";
		table +=         "<td class='calenButton' Author = 'calendar'>";
		table +=           "<div class='calenSetnull' Author = 'calendar'><a href='javascript:clearCalendarControl();' Author = 'calendar'>清 空</a></div>";
		
		//判断是否今天可选
		if(todayDate-mincDate<0||todayDate-maxcDate>0){
			table +=           "<div class='calenSetoday' Author = 'calendar'>今 天</div>";
			}
		else{
			table +=           "<div class='calenSetoday' Author = 'calendar'><a href=\"javascript:setCalendarControlDate("+getCurrentYear()+","+getCurrentMonth()+","+getCurrentDay()+")\"' Author = 'calendar'>今 天</a></div>";
			}
			
		table +=           "<div class='calenClosefl' Author = 'calendar'><a href='javascript:hideCalendarControl();' Author = 'calendar'>关 闭</a></div>";
		table +=         "</td>";
		table +=       "</tr>";
		table +=     "</table>";
		table +=     "</td>";
		table +=   "</tr>";
		table += "</table>";
		return table;
	}
	this.show = show;
	function show(field,dateLimitmin,dateLimitmax){
		dateObj = field;
		can_hide = 0;
		var todayDate = new Date(dateTodystr.replace(/-/g, "/")).getTime();
		var maxcDate = new Date(dateLimitmax.replace(/-/g, "/")).getTime();
		var mincDate = new Date(dateLimitmin.replace(/-/g, "/")).getTime();
		if (dateField == field){return;}
		else{dateField = field;}
		if(dateField){
			try {
				var dateString = new String(dateField.value);
				var dateParts = dateString.split("-");
				selectedMonth = parseInt(dateParts[1],10);
				selectedDay = parseInt(dateParts[2],10);
				selectedYear = parseInt(dateParts[0],10);
				}
			catch(e) {}
			}
		if(!(selectedYear && selectedMonth && selectedDay)) {
			selectedMonth = getCurrentMonth();
			selectedDay = getCurrentDay();
			selectedYear = getCurrentYear();
			if(dateLimitmin){//存在最小值是判断最小值与今天的关系,设置默认指向的日期
				if(mincDate>todayDate){
					selectedMonth = dateLimitmin.split("-")[1];
					selectedYear = dateLimitmin.split("-")[0];
					selectedDay = dateLimitmin.split("-")[2];
					}
				}
			if(dateLimitmax){//存在最大值是判断最大值与今天的关系,设置默认指向的日期
				if(maxcDate<todayDate){
					selectedMonth = dateLimitmax.split("-")[1];
					selectedYear = dateLimitmax.split("-")[0];
					selectedDay = dateLimitmax.split("-")[2];
					}
				}
			}
		currentMonth = selectedMonth;
		currentDay = selectedDay;
		currentYear = selectedYear;	
		if(document.getElementById){//设置日历控件的显示状态和位置
			calendar = document.getElementById(calendarId);
			calendar.innerHTML = calendarDrawTable(dateObj,dateLimitmin,dateLimitmax);
			setProperty('display', 'block');
			
			var fieldPos = new positionInfo(dateField);
			var calendarPos = new positionInfo(calendarId);
			var x = fieldPos.getElementLeft();
			var y = fieldPos.getElementBottom();
			
			setProperty('left', x + "px");
			setProperty('top', y + "px");
			
			if (document.all) {
				setElementProperty('display', 'block', 'CalendarControlIFrame');
				setElementProperty('left', x + "px", 'CalendarControlIFrame');
				setElementProperty('top', y + "px", 'CalendarControlIFrame');
				setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
				setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
				}
			}
		}

	this.hide = hide;
	function hide() {
		if(dateField) {
			setProperty('display', 'none');
			setElementProperty('display', 'none', 'CalendarControlIFrame');
			dateField = null;
			}
		}
	
	
	this.visible = visible;
	function visible() {
		return dateField
		}
	
	this.can_hide = can_hide;
	var can_hide = 0;
	}

var calendarControl = new CalendarControl();
var dateTodystr = getCurrentYear()+"-"+getCurrentMonth()+"-"+getCurrentDay();
function showCalendarControl(textField,limitDate) {
	butObject = textField;
	if(!limitDate){calendarControl.show(textField,'','');}
	else{
		var dateLimitmax;
		var dateLimitmin;
		if(limitDate != ""){
			var str = limitDate.split('^');
			for(i=0;i<str.length;i++){
				if(str[i].substring(0,7) == 'maxDate'){dateLimitmax = str[i];}
				if(str[i].substring(0,7) == 'minDate'){dateLimitmin = str[i];}
				}
			if(dateLimitmin){
				var minstr = dateLimitmin.substring(8);//得到最小限制的条件
				var minstrarr = minstr.split('||');
				if(minstrarr.length ==2){//如果最小值限制有两个的情况下
					var mindaystr1;
					var mindaystr2;
					for(j=0;j<minstrarr.length;j++){
						if(minstrarr[j]=='#today'){mindaystr1 = dateTodystr;}
						else{
							if(minstrarr[j].split('-').length == 3){//如果限制日期为1900-01-01这种格式的情况下
								mindaystr2 = minstrarr[j];
								}
							else{
								if(minstrarr[j].split('(').length==1){//如果限制日期格式中没有天数限制的情况下
									if(document.getElementById(minstrarr[j].split('(')[0])){
										var otherObj = document.getElementById(minstrarr[j].split('(')[0])
										if(otherObj.value != null){
											mindaystr2 = otherObj.value;
											}
										else{mindaystr2 =""}
										}
									}
								else if(minstrarr[j].split('(')[0] == "#today"){
									var d = minstrarr[j].split('(')[1].substring(2).split(')')[0];
									var hiday = new Date();
									reday = new Date(dateTodystr.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
									hiday.setTime(reday);
									var hidayY = hiday.getYear();
									var hidayM = hiday.getMonth()+1;;
									var hidayD = hiday.getDate();
									if(hidayY<1900){hidayY+=1900}
									mindaystr1 = hidayY+"-"+hidayM+"-"+hidayD;	///////////						
								}
								else if(document.getElementById(minstrarr[j].split('(')[0])){//如果限制天数与其它控件日期做对比情况下
									var otherObj = document.getElementById(minstrarr[j].split('(')[0])
									if(otherObj.value != ""){
										var d = minstrarr[j].split('(')[1].substring(2).split(')')[0];
										var hiday = new Date();
										reday = new Date(otherObj.value.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
										hiday.setTime(reday);
										var hidayY = hiday.getYear();
										var hidayM = hiday.getMonth()+1;;
										var hidayD = hiday.getDate();
										if(hidayY<1900){hidayY+=1900}
										mindaystr2 = hidayY+"-"+hidayM+"-"+hidayD;
										}
									else if(otherObj.value == ""){mindaystr2 =""}
									}
								}	
							}
						}
					//计算在两个时间中最小值
					if(mindaystr2 != ""){
						var val = new Date(mindaystr1.replace(/-/g, "/")).getTime() - new Date(mindaystr2.replace(/-/g, "/")).getTime();
						if(val >= 0){dateLimitmin = mindaystr1;}
						else{dateLimitmin = mindaystr2;}
						}
					else{dateLimitmin = mindaystr1;}
					}
				else if(minstrarr.length ==1){//如果最小值限制只有一个的情况下
					if(minstr=='#today'){//只限制为今天日期格式的情况下
						dateLimitmin = dateTodystr;
						}
					else if(minstr.split('-').length == 3){//如果限制日期为1900-01-01这种格式的情况下
						dateLimitmin = minstr;
						}
					else if(minstr.split('(').length==1){//如果限制日期格式中没有天数限制的情况下
						if(document.getElementById(minstr.split('(')[0])){
							var otherObj = document.getElementById(minstr.split('(')[0])
							if(otherObj.value != null){
								dateLimitmin = otherObj.value;
								}
							else{dateLimitmin =""}
							}
						}
					else if(minstr.split('(').length==2){//如果有天数限制的情况下
						if(minstr.split('(')[0] == '#today'){//如果限制天数与当前日期做对比的情况下
							var hiday = new Date();
							var d = minstr.split('(')[1].substring(2).split(')')[0];
							reday = new Date(dateTodystr.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
							hiday.setTime(reday);
							var hidayY = hiday.getYear();
							var hidayM = hiday.getMonth()+1;;
							var hidayD = hiday.getDate();
							if(hidayY<1900){hidayY+=1900}
							dateLimitmin = hidayY+"-"+hidayM+"-"+hidayD;
							}
						else if(document.getElementById(minstr.split('(')[0])){//如果限制天数与其它控件日期做对比情况下
							var otherObj = document.getElementById(minstr.split('(')[0])
							if(otherObj.value != ""){
								var d = minstr.split('(')[1].substring(2).split(')')[0];
								var hiday = new Date();
								reday = new Date(otherObj.value.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
								hiday.setTime(reday);
								var hidayY = hiday.getYear();
								var hidayM = hiday.getMonth()+1;;
								var hidayD = hiday.getDate();
								if(hidayY<1900){hidayY+=1900}
								dateLimitmin = hidayY+"-"+hidayM+"-"+hidayD;
								}
							else if(otherObj.value == ""){dateLimitmin =""}
							}
						}
					}
				}
			else{dateLimitmin=""}
			if(dateLimitmax){
				var maxstr = dateLimitmax.substring(8);//得到最大限制的条件
				var maxstrarr = maxstr.split('||');
				if(maxstrarr.length ==2){//如果最大值限制有两个的情况下
					var maxdaystr1;
					var maxdaystr2;
					for(j=0;j<maxstrarr.length;j++){
						if(maxstrarr[j]=='#today'){maxdaystr1 = dateTodystr;}
						else{
							if(maxstrarr[j].split('-').length == 3){//如果限制日期为1900-01-01这种格式的情况下
								maxdaystr2 = maxstrarr[j];
								}
							else{
								if(maxstrarr[j].split('(').length==1){//如果限制日期格式中没有天数限制的情况下
									if(document.getElementById(maxstrarr[j].split('(')[0])){
										var otherObj = document.getElementById(maxstrarr[j].split('(')[0])
										if(otherObj.value != null){
											maxdaystr2 = otherObj.value;
											}
										else{maxdaystr2 =""}
										}
									}
								else if(maxstrarr[j].split('(')[0] == "#today"){
									var d = maxstrarr[j].split('(')[1].substring(2).split(')')[0];
									var hiday = new Date();
									reday = new Date(dateTodystr.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
									hiday.setTime(reday);
									var hidayY = hiday.getYear();
									var hidayM = hiday.getMonth()+1;;
									var hidayD = hiday.getDate();
									if(hidayY<1900){hidayY+=1900}
									maxdaystr1 = hidayY+"-"+hidayM+"-"+hidayD;	///////////						
								}
								else if(document.getElementById(maxstrarr[j].split('(')[0])){//如果限制天数与其它控件日期做对比情况下
									var otherObj = document.getElementById(maxstrarr[j].split('(')[0])
									if(otherObj.value != ""){
										var d = maxstrarr[j].split('(')[1].substring(2).split(')')[0];
										var hiday = new Date();
										reday = new Date(otherObj.value.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
										hiday.setTime(reday);
										var hidayY = hiday.getYear();
										var hidayM = hiday.getMonth()+1;;
										var hidayD = hiday.getDate();
										if(hidayY<1900){hidayY+=1900}
										maxdaystr2 = hidayY+"-"+hidayM+"-"+hidayD;
										}
									else if(otherObj.value == ""){maxdaystr2 =""}
									}
								}	
							}
						}
					//计算在两个时间中最小值
					if(maxdaystr2 != ""){
						var val = new Date(maxdaystr1.replace(/-/g, "/")).getTime() - new Date(maxdaystr2.replace(/-/g, "/")).getTime();
						if(val >= 0){dateLimitmax = maxdaystr2;}
						else{dateLimitmax = maxdaystr1;}
						}
					else{dateLimitmax = maxdaystr1;}
					}
				else if(maxstrarr.length ==1){//如果最小值限制只有一个的情况下
					if(maxstr=='#today'){//只限制为今天日期格式的情况下
						dateLimitmax = dateTodystr;
						}
					else if(maxstr.split('-').length == 3){//如果限制日期为1900-01-01这种格式的情况下
						dateLimitmax = maxstr;
						}
					else if(maxstr.split('(').length==1){//如果限制日期格式中没有天数限制的情况下
						if(document.getElementById(maxstr.split('(')[0])){
							var otherObj = document.getElementById(maxstr.split('(')[0])
							if(otherObj.value != null){
								dateLimitmax = otherObj.value;
								}
							else{dateLimitmax =""}
							}
						}
					else if(maxstr.split('(').length==2){//如果有天数限制的情况下
						if(maxstr.split('(')[0] == '#today'){//如果限制天数与当前日期做对比的情况下
							var hiday = new Date();
							var d = maxstr.split('(')[1].substring(2).split(')')[0];
							reday = new Date(dateTodystr.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
							hiday.setTime(reday);
							var hidayY = hiday.getYear();
							var hidayM = hiday.getMonth()+1;;
							var hidayD = hiday.getDate();
							if(hidayY<1900){hidayY+=1900}
							dateLimitmax = hidayY+"-"+hidayM+"-"+hidayD;
							}
						else if(document.getElementById(maxstr.split('(')[0])){//如果限制天数与其它控件日期做对比情况下
							var otherObj = document.getElementById(maxstr.split('(')[0])
							if(otherObj.value != ""){
								var d = maxstr.split('(')[1].substring(2).split(')')[0];
								var hiday = new Date();
								reday = new Date(otherObj.value.replace(/-/g, "/")).getTime()+(d*24*60*60*1000);
								hiday.setTime(reday);
								var hidayY = hiday.getYear();
								var hidayM = hiday.getMonth()+1;;
								var hidayD = hiday.getDate();
								if(hidayY<1900){hidayY+=1900}
								dateLimitmax = hidayY+"-"+hidayM+"-"+hidayD;
								}
							else if(otherObj.value == ""){dateLimitmax =""}
							}
						}		
					}
				}
			else{dateLimitmax=""}					
			}
		if(limitDate==""){
			dateLimitmax="";
			dateLimitmin="";
			}
		calendarControl.show(textField,dateLimitmin,dateLimitmax);
		}
		
	}

function clearCalendarControl() {
	calendarControl.clearDate();
	}

function hideCalendarControl() {
	if (calendarControl.visible()) {calendarControl.hide();}
	}

function setCalendarControlDate(year, month, day){
	calendarControl.setDate(year, month, day);
	}

function changeCalendarControlYear(change,dmax,dmin){
	calendarControl.changeYear(change,dmax,dmin);
	}

function changeCalendarControlMonth(change,dmax,dmin){
	calendarControl.changeMonth(change,dmax,dmin);
	}



//实现外部点击日期控件消失
document.onclick = eVclick;
function eVclick(event){
	event = (event == null)?window.event:event;
	var srcelement= event.target?event.target:event.srcElement;//获取鼠点击标对象
	if(srcelement.getAttribute("Author")==null && srcelement != document.getElementById("calendarCov") && srcelement != butObject){
		hideCalendarControl();
		}
	}
	
	
document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no' Author = 'calendar'></iframe>");
document.write("<div id='calendarCov' Author = 'calendar'></div>");

